home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / modula2 / 492 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.8 KB

  1. Path: scratchy.mi.net!tad!will.burrow
  2. From: will.burrow@tad.com (WILL BURROW)
  3. Newsgroups: comp.lang.modula2
  4. Subject: Re: SIZE function for FST
  5. Message-ID: <8BDB322.0135000271.uuout@tad.com>
  6. Date: Sat, 30 Mar 96 13:22:00 -0700
  7. Distribution: world
  8. Organization: TRANS ATLANTIC DIMENSIONS
  9. Reply-To: will.burrow@tad.com (WILL BURROW)
  10. References: <31517683.793C@dmu.ac.uk>
  11. X-Newsreader: PCBoard Version 15.22
  12. X-Mailer: PCBoard/UUOUT Version 1.20
  13.  
  14.   Graham Perkins,
  15.   In a message on 21 March, wrote :
  16.  
  17. GP> Jeffrey E Stoner wrote:
  18. GP> > Ronald Snelgrove (ronald@newton.physics.BrockU.CA) wrote:
  19. GP> > : To anyone using the Fitted Software Modula-2 compiler for DOS:
  20. GP> > : of bytes required to store that type, ie SIZE(INTEGER) would return 2
  21. GP> s
  22. GP> > 
  23. GP> > Well, in the manual, pages 21-22 lists the amount of storage for each d
  24. GP> > type.  Simply count 'em up.
  25. GP> > 
  26. GP> 
  27. GP> No, no!  That won't help!  He is trying to write software that does
  28. GP> some stuff regardless of what size the data item is.  OK so he could
  29. GP> count up and use a numeric literal, but then the software would need
  30. GP> changing in lots of places if the data item ever changed.  And the
  31. GP> compiler won't check you've made all those changes.  And the runtime
  32. GP> might not show any obvious faults for a while.
  33. GP> 
  34. GP> I needed that SIZE function for my file handling modules I just
  35. GP> wrote.  The definition module contains 
  36. <snip>
  37. GP> the imp. module are a load of SIZE(Item) calls needed to cope with
  38. GP> all that low level "ReadNBytes" stuff.  
  39. GP> 
  40. GP> I can make this (and sequential and relative files) work for Topspees,
  41. GP> Gardens Point, and Logitech.  But it looks like it wouldn't be possible
  42. GP> for Fitted Software.
  43. GP> 
  44. GP> Ronald might like to try writing his own SIZE function, but I think
  45. GP> the only way would be via a paremeter of type ARRAY OF BYTE and I'm
  46. GP> not sure if Fitted Software M2 supports that.
  47.  
  48. What is broken?
  49. The following program works (see output below):
  50.  
  51.  
  52. MODULE Testaofb;
  53.  
  54. FROM InOut IMPORT WriteCard, WriteString, WriteLn;
  55. FROM SYSTEM IMPORT BYTE;
  56.  
  57. PROCEDURE Passaofb( x: ARRAY OF BYTE );
  58. BEGIN
  59.     WriteCard( SIZE( x ), 5 );
  60. END Passaofb;
  61.  
  62. VAR n: INTEGER;
  63.     s: ARRAY [0..10] OF CHAR;
  64.     l: LONGCARD;
  65. BEGIN
  66.     WriteString("              INTEGER: ");    Passaofb( n );
  67.     WriteString("  ");  WriteCard( SIZE( n ), 5 );
  68.     WriteLn;
  69.  
  70.     WriteString("ARRAY [0..10] OF CHAR: ");    Passaofb( s );
  71.     WriteString("  ");  WriteCard( SIZE( s ), 5 );
  72.     WriteLn;
  73.  
  74.     WriteString("             LONGCARD: ");    Passaofb( l );
  75.     WriteString("  ");  WriteCard( SIZE( l ), 5 );
  76.     WriteLn;
  77. END Testaofb.
  78.  
  79. Output is as follows:
  80.  
  81.               INTEGER:     2      2
  82. ARRAY [0..10] OF CHAR:    11     11
  83.              LONGCARD:     4      4
  84.  
  85. Perhaps you are refering to opaque types or something?
  86.  
  87. Will.
  88.   
  89. ...
  90.  * ATP/Linux 1.42 * and now Jeanette MacDonald with "Beyond the Blue Horizon"
  91.  
  92.